﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <div>
    <el-form ref="formRefProductBOM" :model="stateProductBOM.vmModel" label-width="100px">
      <el-row>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_FactoryCode_FormItem" prop="Entity.FactoryCode" :label="$t('message.autotrans._Model_ProductBOM_factoryCode')">
            <el-input v-model="stateProductBOM.vmModel.Entity.FactoryCode" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Assemblyline_FormItem" prop="Entity.Assemblyline" :label="$t('message.autotrans._Model_ProductBOM_assemblyline')">
            <el-input v-model="stateProductBOM.vmModel.Entity.Assemblyline" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_OperationCode_FormItem" prop="Entity.OperationCode" :label="$t('message.autotrans._Model_ProductBOM_operationCode')">
            <el-input v-model="stateProductBOM.vmModel.Entity.OperationCode" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_OrderCode_FormItem" prop="Entity.OrderCode" :label="$t('message.autotrans._Model_ProductBOM_orderCode')">
            <el-input v-model="stateProductBOM.vmModel.Entity.OrderCode" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_ScheduleNumber_FormItem" prop="Entity.ScheduleNumber" :label="$t('message.autotrans._Model_ProductBOM_scheduleNumber')">
            <el-input v-model="stateProductBOM.vmModel.Entity.ScheduleNumber" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_AddTime_FormItem" prop="Entity.AddTime" :label="$t('message.autotrans._Model_ProductBOM_addTime')">
            <el-input v-model="stateProductBOM.vmModel.Entity.AddTime" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_AssemblyConsumption_FormItem" prop="Entity.AssemblyConsumption" :label="$t('message.autotrans._Model_ProductBOM_assemblyConsumption')">
            <el-input v-model="stateProductBOM.vmModel.Entity.AssemblyConsumption" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_AssemblyMaterialCode_FormItem" prop="Entity.AssemblyMaterialCode" :label="$t('message.autotrans._Model_ProductBOM_assemblyMaterialCode')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProductBOM_assemblyMaterialCode')}), trigger: 'blur' }]" >
            <el-input v-model="stateProductBOM.vmModel.Entity.AssemblyMaterialCode" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_AssemblyMaterialId_FormItem" prop="Entity.AssemblyMaterialId" :label="$t('message.autotrans._Model_ProductBOM_assemblyMaterialId')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProductBOM_assemblyMaterialId')}), trigger: 'blur' }]" >
            <el-input v-model="stateProductBOM.vmModel.Entity.AssemblyMaterialId" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_AssemblyMaterialName_FormItem" prop="Entity.AssemblyMaterialName" :label="$t('message.autotrans._Model_ProductBOM_assemblyMaterialName')">
            <el-input v-model="stateProductBOM.vmModel.Entity.AssemblyMaterialName" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_AssemblyMaterialRegex_FormItem" prop="Entity.AssemblyMaterialRegex" :label="$t('message.autotrans._Model_ProductBOM_assemblyMaterialRegex')">
            <el-input v-model="stateProductBOM.vmModel.Entity.AssemblyMaterialRegex" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_AssemblyMaterialVersion_FormItem" prop="Entity.AssemblyMaterialVersion" :label="$t('message.autotrans._Model_ProductBOM_assemblyMaterialVersion')">
            <el-input v-model="stateProductBOM.vmModel.Entity.AssemblyMaterialVersion" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_AssemblyUnitCode_FormItem" prop="Entity.AssemblyUnitCode" :label="$t('message.autotrans._Model_ProductBOM_assemblyUnitCode')">
            <el-input v-model="stateProductBOM.vmModel.Entity.AssemblyUnitCode" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_AutoMaterialDeduction_FormItem" prop="Entity.AutoMaterialDeduction" :label="$t('message.autotrans._Model_ProductBOM_autoMaterialDeduction')">
            <el-input v-model="stateProductBOM.vmModel.Entity.AutoMaterialDeduction" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_EditTime_FormItem" prop="Entity.EditTime" :label="$t('message.autotrans._Model_ProductBOM_editTime')">
            <el-input v-model="stateProductBOM.vmModel.Entity.EditTime" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Field1_FormItem" prop="Entity.Field1" label="产品校验">
            <el-input v-model="stateProductBOM.vmModel.Entity.Field1" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Field2_FormItem" prop="Entity.Field2" :label="$t('message.autotrans._Model_ProductBOM_field2')">
            <el-input v-model="stateProductBOM.vmModel.Entity.Field2" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Field3_FormItem" prop="Entity.Field3" :label="$t('message.autotrans._Model_ProductBOM_field3')">
            <el-input v-model="stateProductBOM.vmModel.Entity.Field3" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Field4_FormItem" prop="Entity.Field4" :label="$t('message.autotrans._Model_ProductBOM_field4')">
            <el-input v-model="stateProductBOM.vmModel.Entity.Field4" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Field5_FormItem" prop="Entity.Field5" :label="$t('message.autotrans._Model_ProductBOM_field5')">
            <el-input v-model="stateProductBOM.vmModel.Entity.Field5" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_IsDelete_FormItem" prop="Entity.IsDelete" :label="$t('message.autotrans._Model_ProductBOM_isDelete')">
            <el-input v-model="stateProductBOM.vmModel.Entity.IsDelete" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_MaterialCode_FormItem" prop="Entity.MaterialCode" :label="$t('message.autotrans._Model_ProductBOM_materialCode')">
            <el-input v-model="stateProductBOM.vmModel.Entity.MaterialCode" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_MaterialId_FormItem" prop="Entity.MaterialId" :label="$t('message.autotrans._Model_ProductBOM_materialId')">
            <el-input v-model="stateProductBOM.vmModel.Entity.MaterialId" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_MaterialName_FormItem" prop="Entity.MaterialName" :label="$t('message.autotrans._Model_ProductBOM_materialName')">
            <el-input v-model="stateProductBOM.vmModel.Entity.MaterialName" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_MaterialRegex_FormItem" prop="Entity.MaterialRegex" :label="$t('message.autotrans._Model_ProductBOM_materialRegex')">
            <el-input v-model="stateProductBOM.vmModel.Entity.MaterialRegex" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_MaterialSort_FormItem" prop="Entity.MaterialSort" :label="$t('message.autotrans._Model_ProductBOM_materialSort')">
            <el-input v-model="stateProductBOM.vmModel.Entity.MaterialSort" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_MaterialVersion_FormItem" prop="Entity.MaterialVersion" :label="$t('message.autotrans._Model_ProductBOM_materialVersion')">
            <el-input v-model="stateProductBOM.vmModel.Entity.MaterialVersion" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_OrderId_FormItem" prop="Entity.OrderId" :label="$t('message.autotrans._Model_ProductBOM_orderId')">
            <el-input v-model="stateProductBOM.vmModel.Entity.OrderId" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_OrderQty_FormItem" prop="Entity.OrderQty" :label="$t('message.autotrans._Model_ProductBOM_orderQty')">
            <el-input v-model="stateProductBOM.vmModel.Entity.OrderQty" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_ProductBomId_FormItem" prop="Entity.ProductBomId" :label="$t('message.autotrans._Model_ProductBOM_productBomId')">
            <el-input v-model="stateProductBOM.vmModel.Entity.ProductBomId" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_ReplaceMaterialList_FormItem" prop="Entity.ReplaceMaterialList" :label="$t('message.autotrans._Model_ProductBOM_replaceMaterialList')">
            <el-input v-model="stateProductBOM.vmModel.Entity.ReplaceMaterialList" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Replaces_FormItem" prop="Entity.Replaces" :label="$t('message.autotrans._Model_ProductBOM_replaces')">
            <el-input v-model="stateProductBOM.vmModel.Entity.Replaces" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_Retroactive_FormItem" prop="Entity.Retroactive" :label="$t('message.autotrans._Model_ProductBOM_retroactive')">
            <el-input v-model="stateProductBOM.vmModel.Entity.Retroactive" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_RouteBomCode_FormItem" prop="Entity.RouteBomCode" :label="$t('message.autotrans._Model_ProductBOM_routeBomCode')">
            <el-input v-model="stateProductBOM.vmModel.Entity.RouteBomCode" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_RouteBomName_FormItem" prop="Entity.RouteBomName" :label="$t('message.autotrans._Model_ProductBOM_routeBomName')">
            <el-input v-model="stateProductBOM.vmModel.Entity.RouteBomName" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_RouteNumber_FormItem" prop="Entity.RouteNumber" :label="$t('message.autotrans._Model_ProductBOM_routeNumber')">
            <el-input v-model="stateProductBOM.vmModel.Entity.RouteNumber" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_ShipRegularCheck_FormItem" prop="Entity.ShipRegularCheck" :label="$t('message.autotrans._Model_ProductBOM_shipRegularCheck')">
            <el-input v-model="stateProductBOM.vmModel.Entity.ShipRegularCheck" disabled clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Entity_ShopOrderOperationMaterialId_FormItem" prop="Entity.ShopOrderOperationMaterialId" :label="$t('message.autotrans._Model_ProductBOM_shopOrderOperationMaterialId')">
            <el-input v-model="stateProductBOM.vmModel.Entity.ShopOrderOperationMaterialId" disabled clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

      <div style="text-align:right;">
        <WtmButton @click="onCloseProductBOM"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

      </div>

    </el-form>

  </div>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageBaseInformationProductBOMDetails;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { productbomApi } from '/@/api/baseinformation/productbom';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const formRefProductBOM = ref();
const stateProductBOM = reactive({
    vmModel: {
	  Entity:{
        FactoryCode: '',
        Assemblyline: '',
        OperationCode: '',
        OrderCode: '',
        ScheduleNumber: '',
        AddTime: '',
        AssemblyConsumption: '',
        AssemblyMaterialCode: '',
        AssemblyMaterialId: '',
        AssemblyMaterialName: '',
        AssemblyMaterialRegex: '',
        AssemblyMaterialVersion: '',
        AssemblyUnitCode: '',
        AutoMaterialDeduction: null,
        EditTime: '',
        Field1: '',
        Field2: '',
        Field3: '',
        Field4: '',
        Field5: '',
        IsDelete: '',
        MaterialCode: '',
        MaterialId: '',
        MaterialName: '',
        MaterialRegex: '',
        MaterialSort: '',
        MaterialVersion: '',
        OrderId: '',
        OrderQty: '',
        ProductBomId: '',
        ReplaceMaterialList: '',
        Replaces: null,
        Retroactive: '',
        RouteBomCode: '',
        RouteBomName: '',
        RouteNumber: '',
        ShipRegularCheck: '',
        ShopOrderOperationMaterialId: '',
        ID:null,
      },

	},
    
});

// 取消
const onCloseProductBOM = () => {
    closeDialog();
};

// 提交
const onSubmitProductBOM = () => {
 	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});
   formRefProductBOM.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            productbomApi().edit(stateProductBOM.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
	})
};

// 页面加载时
onMounted(() => {
    
    if (ci.attrs["wtmdata"]) {
		stateProductBOM.vmModel.Entity.ID = ci.attrs["wtmdata"].ID;
	}
	else if (useRouter().currentRoute.value.query.id) {
		stateProductBOM.vmModel.Entity.ID = useRouter().currentRoute.value.query.id as any;
	}
	productbomApi().get(stateProductBOM.vmModel.Entity.ID ?? "").then((data: any) => other.setValue(stateProductBOM.vmModel, data));
});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

